package com.xiaoyu.lanling.feature.vip.viewholder

import `in`.srain.cube.views.list.ViewHolderBase
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.facebook.drawee.view.SimpleDraweeView
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.feature.vip.model.PrivilegeItem
import com.xiaoyu.lanling.media.image.ImageLoadParam
import com.xiaoyu.lanling.media.image.ImageViewUtil

class PrivilegeViewHolder : ViewHolderBase<PrivilegeItem>() {

    private var mIcon: SimpleDraweeView? = null
    private var mTitle: TextView? = null
    private var mDesc: TextView? = null

    override fun createView(layoutInflater: LayoutInflater, parent: ViewGroup): View? {
        val view = layoutInflater.inflate(R.layout.vip_product_privilege_item, parent, false)
        mIcon = view.findViewById(R.id.privilege_icon)
        mTitle = view.findViewById(R.id.privilege_title)
        mDesc = view.findViewById(R.id.privilege_desc)
        return view
    }

    override fun showData(position: Int, itemData: PrivilegeItem) {
        ImageViewUtil.loadImage(mIcon, ImageLoadParam.newBuilder().setUrl(itemData.iconUrl).setSizeInDP(48).build())
        mTitle?.text = itemData.name
        mDesc?.text = itemData.description
    }
}